package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.PositionEntity;
import com.example.demo.entity.UserEntity;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserMapper extends BaseMapper<UserEntity> {

    @Select("select * from user where name = #{userName}")
    UserEntity findUser(@Param("userName")String userName);

    @Select("select post_id from share where user_id = #{userId}")
    List<String> findSharePositionId(String userId);

    @Insert("insert into share(id,post_id,user_id) values(#{id},#{positionId},#{userId})")
    void insertSharePosition(String id,String positionId,String userId);

}
